﻿// ===============================================================================
// DotNet.Platform 开发框架 2016 版权所有
// ===============================================================================

using System;
using DotNet.Entity;
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;

namespace DotNet.Core.Entity
{
    /// <summary>
    /// 文章分类
    /// </summary>
    [Table("文章分类")]    
    public class ArticleCategory
    {
		/// <summary>
        /// 主键
        /// </summary>
        [PrimaryKey]
        [Column("主键",false)]
        public string Id { get; set; }

        /// <summary>
        /// 上级主键
        /// </summary>
        [ParentKey]
        [Column("上级主键")]
        [JsonProperty("_parentId", NullValueHandling = NullValueHandling.Ignore)]
        public string ParentId { get; set; }

		/// <summary>
        /// 分类名称
        /// </summary>
		[Column("分类名称")]
        [TextKey]
        [Required(ErrorMessage = "请输入名称")]
        [MaxLength(50, ErrorMessage = "名称长度不能超过{0}个字符")]
        public string Name { get; set; }

        /// <summary>
        /// 排序路径
        /// </summary>
        [Column("排序路径")]
        [SortPath]
        public string SortPath { get; set; }

        /// <summary>
        /// 展开状态
        /// </summary>
        [Ignore]
        public bool IsExpand { get; set; } = true;

        /// <summary>
        /// 复制对象
        /// </summary>
        public ArticleCategory Clone()
        {
            return (ArticleCategory)MemberwiseClone();
        }
    }
}
